//
// SoapTrace.Net - A soap message monitoring utility. 
//
// Copyright (C) 2005 Matthew Ward
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)

using NUnit.Framework;
using SoapTrace.Core.Formatters;
using System;

namespace SoapTrace.Tests.FormatterManagement
{
	/// <summary>
	/// Tests the <see cref="MessageFormatterManager"/>'s handling
	/// of no custom message formatters.
	/// </summary>
	[ TestFixture ]
	public class NoCustomFormattersTestFixture
	{
		MessageFormatterManager Manager;
		SimpleMessageFormatter Formatter;
		
		/// <summary>
		/// Initialises each test.
		/// </summary>
		[ SetUp ]
		public void Init( )
		{
			MessageFormatterEntryCollection Entries = new MessageFormatterEntryCollection( );
			
			Manager = new MessageFormatterManager( Entries );
			
			Manager.ShowSoapHeaders = true;
			Manager.ShowSoapMessageParameters = false;
			Manager.ShowRawSoapMessage = true;
			Manager.ShowSoapEnvelope = true;
			
			Formatter = ( SimpleMessageFormatter )Manager.CurrentFormatter;
		}
		
		/// <summary>
		/// Checks that no custom message formatters are
		/// set up.
		/// </summary>
		[ Test ]
		public void FormatterCount( )
		{
			Assert.AreEqual( 0, Manager.GetCustomFormatterNames( ).Length, "Not expecting any custom formatters." );
		}
		
		/// <summary>
		/// Checks the show soap headers has been set.
		/// </summary>
		[ Test ]
		public void ShowSoapHeaders( )
		{
			Assert.IsTrue( Formatter.ShowSoapHeaders, "Show soap headers should be true." );
		}
		
		/// <summary>
		/// Checks the show soap headers has been changed.
		/// </summary>
		[ Test ]
		public void ChangeShowSoapHeaders( )
		{
			Manager.ShowSoapHeaders = false;
			
			Assert.IsFalse( Formatter.ShowSoapHeaders, "Show soap headers should be false." );
		}		
		
		/// <summary>
		/// Checks the show soap message params has been set.
		/// </summary>
		[ Test ]
		public void ShowSoapMessageParams( )
		{
			Assert.IsFalse( Formatter.ShowSoapMessageParameters, "Show soap message params should be false." );
		}
		
		/// <summary>
		/// Checks the show soap message params has been changed.
		/// </summary>
		[ Test ]
		public void ChangeShowSoapMessageParams( )
		{
			Manager.ShowSoapMessageParameters = true;
			
			Assert.IsTrue( Formatter.ShowSoapMessageParameters, "Show soap message params should be true." );
		}	
		
		/// <summary>
		/// Checks the show raw soap message flag has been set.
		/// </summary>
		[ Test ]
		public void ShowRawSoapMessage( )
		{
			Assert.IsFalse( Formatter.FormatSoapMessage, "Show formatted soap message should be false." );
		}
		
		/// <summary>
		/// Checks the show raw soap message has been changed.
		/// </summary>
		[ Test ]
		public void ChangeFormatSoapMessage( )
		{
			Manager.ShowRawSoapMessage = false;
			
			Assert.IsTrue( Formatter.FormatSoapMessage, "Show formatted soap message should be true." );
		}
		
		/// <summary>
		/// Checks the show soap envelope has been set.
		/// </summary>
		[ Test ]
		public void ShowSoapEnvelope( )
		{
			Assert.IsTrue( Formatter.ShowSoapEnvelope, "Show soap envelope should be true." );
		}
		
		/// <summary>
		/// Checks the show soap envelope has been changed.
		/// </summary>
		[ Test ]
		public void ChangeShowSoapEnvelope( )
		{
			Manager.ShowSoapEnvelope = false;
			
			Assert.IsFalse( Formatter.ShowSoapEnvelope, "Show soap envelope should be false." );
		}		
	}
}
